<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>

<body>
<?php
date_default_timezone_set("PRC");
include "../mysql/mysql.php";
$aa = new mysql;
$aa->link("");
include "../myfunction.php";
$bb= new myfunction; 

$email = $bb->test_input(@$_POST['mail'] );
//$email = '1198128405@qq.com';
// var_dump($email);
$sql = $bb->finduser($email);  
 
if($sql == ''){//该邮箱尚未注册！ 
echo 'noreg'; 
exit; 
}else{ 

$randcode = $bb->randcode(6);
$time = date('Y-m-d H:i:s');
$sql = "UPDATE user_info SET token= '".$randcode."' WHERE user_name='".$email."' ";
$result= $aa->excu($sql);
$sql = "UPDATE user_info SET timecode= '".$time."' WHERE user_name='".$email."' ";
$result= $aa->excu($sql);

if($result == 'TURE'){
	 
	$result = 1;
	//sendmail($time, $email, $randcode);
	}
 
if($result == 1){//邮件发送成功 
$msg = '系统已向您的邮箱发送了一封邮件,请登录到您的邮箱获取验证码！'; 
}else{ 
$msg = $result; 
} 
echo $msg; 
} 
 
//发送邮件 
function sendmail($time,$email,$url){ 
include_once("smtp.class.php"); 
$smtpserver = ""; //SMTP服务器，如smtp.163.com 
$smtpserverport = 25; //SMTP服务器端口 
$smtpusermail = ""; //SMTP服务器的用户邮箱 
$smtpuser = ""; //SMTP服务器的用户帐号 
$smtppass = ""; //SMTP服务器的用户密码 
$smtp = new Smtp($smtpserver, $smtpserverport, true, $smtpuser, $smtppass); 
//这里面的一个true是表示使用身份验证,否则不使用身份验证. 
$emailtype = "HTML"; //信件类型，文本:text；网页：HTML 
$smtpemailto = $email; 
$smtpemailfrom = $smtpusermail; 
$emailsubject = "锤子科技商城 - 找回密码"; 
$emailbody = "亲爱的".$email."：<br/>您在".$time."提交了找回密码请求。找回密码验证码为：".$randcode."
（验证码十分钟内有效）。<br/>"; 
$rs = $smtp->sendmail($smtpemailto, $smtpemailfrom, $emailsubject, $emailbody, $emailtype); 
 
return $rs; 
}



include "../mysql/mysqlclose.php";
?>
</body>
</html>